module.exports = {
  buyIfMacdUpManyDays () {
    const kdjDiff15mOK = this.analysisInfo15m.kdjDiff > 0 ||
      (this.marketFlagInfo.indexIfMarketUpTrend && this.strategy === '1' && this.analysisInfo15m.isKdjIncrease) ||
      (this.strategy === '1' && this.marketFlagInfo.ifMarket4hMacdEmaAllGood && this.marketFlagInfo.ifMarket1hMacdEmaAllGood && this.analysisInfo15m.isKdjIncrease)
    if (
      this.analysisInfo15m.macdUpDays >= 22 &&
      this.analysisInfo15m.ema5W10A20Days >= 18 &&
      kdjDiff15mOK
    ) {
      if (
        (
          this.analysisInfo1h.macdUpDays >= 20 ||
          this.analysisInfo1h.ema5W10A20Days >= 20
        ) &&
        (
          this.analysisInfo4h.macdUpDays >= 20 ||
          this.analysisInfo4h.ema5W10A20Days >= 20
        )
      ) {
        // （确定性最强）
        this.setBuy('buyIfMacdUpManyDays-1', {
          canReverse: true
        })
      }
    }
    // macd20天，如果510也有20天，然后当前是51020那也行
    if (
      this.analysisInfo15m.macdUpDays >= 20 &&
      this.analysisInfo15m.ema5A10Days >= 20 &&
      this.analysisInfo15m.ema5A10A20Days >= 1 &&
      kdjDiff15mOK
    ) {
      if (
        this.analysisInfo1h.macdUpDays >= 2
      ) {
        this.setBuy('buyIfMacdUpManyDays-2', {
          canReverse: true
        })
      }
    }
    if (
      this.analysisInfo15m.macdUpDays >= 20 &&
      this.analysisInfo15m.ema5W10A20Days >= 20 &&
      kdjDiff15mOK
    ) {
      this.setBuy('buyIfMacdUpManyDays-3', {
        canReverse: true
      })
    }
    if (
      this.analysisInfo1h.macdUpDays >= 20 &&
      this.analysisInfo1h.ema5W10A20Days >= 20 &&
      this.analysisInfo1h.kdjDiff > 0 &&
      kdjDiff15mOK
    ) {
      if (
        this.analysisInfo4h.macd > 0 &&
        this.analysisInfo4h.ema5A10A20Days >= 1 &&
        (this.analysisInfo1d.macd > 0 || this.analysisInfo1d.ema5W10A20Days >= 1)
      ) {
        if (this.strategy === '2') {
          this.setBuy('buyIfMacdUpManyDays-4-1', {
            canReverse: true
          })
        }
      }
    }
    if (
      this.analysisInfo15m.macdUpDays >= 30 &&
      this.analysisInfo15m.ema5W10A20Days >= 8 &&
      kdjDiff15mOK &&
      this.analysisInfo1h.macd > 0
    ) {
      this.setBuy('buyIfMacdUpManyDays-6', {
        canReverse: true
      })
    }
    if (
      this.analysisInfo1h.macdUpDays >= 30 &&
      this.analysisInfo1h.ema5W10A20Days >= 8 &&
      this.analysisInfo1h.kdjDiff > 0 &&
      this.analysisInfo4h.macd > 0 &&
      kdjDiff15mOK
    ) {
      this.setBuy('buyIfMacdUpManyDays-7', {
        canReverse: true
      })
    }
    if (
      this.analysisInfoFlag15m.countIfMacdUpTimes(38, 33) &&
      this.analysisInfo15m.macdUpDays >= 4 &&
      this.analysisInfo15m.ema5W10A20Days >= 30 &&
      kdjDiff15mOK
    ) {
      if (
        this.analysisInfo1h.macdUpDays >= 4 &&
        this.analysisInfo1h.ema5W10A20Days >= 4 &&
        this.analysisInfo1h.kdjDiff > 0
      ) {
        this.setBuy('buyIfMacdUpManyDays-8', {
          canReverse: true
        })
      }
    }
    if (
      this.analysisInfoFlag15m.countIfMacdUpTimes(38, 33) &&
      this.analysisInfo15m.macdUpDays >= 3 &&
      this.analysisInfo15m.ema5W10A20Days >= 20 &&
      kdjDiff15mOK
    ) {
      if (
        this.analysisInfo1h.macdUpDays >= 4 &&
        this.analysisInfo1h.kdjUpDays >= 8
      ) {
        this.setBuy('buyIfMacdUpManyDays-9', {
          canReverse: true
        })
      }
    }
    if (
      this.analysisInfo1h.macd > 0 &&
      this.analysisInfo1h.ema5W10A20Days >= 25 &&
      this.analysisInfo1h.kdjDiff > 0 &&
      this.analysisInfo15m.macd > 0 &&
      this.analysisInfo15m.ema5A10A20Days >= 1 &&
      kdjDiff15mOK &&
      !(this.strategy === '1' && this.analysisInfo15m.macdUpDays === 1 &&
        !(this.marketFlagInfo.ifMarket1hMacdEmaHasGood || this.marketFlagInfo.ifMarket15mMacdEmaHasGood)
      )
    ) {
      this.setBuy('buyIfMacdUpManyDays-10', {
        canReverse: true
      })
    }
    if (
      this.analysisInfo15m.macd > 0 &&
      this.analysisInfo15m.ema5W10A20Days >= 80 &&
      kdjDiff15mOK
    ) {
      this.setBuy('buyIfMacdUpManyDays-10-1', {
        canReverse: true
      })
    }
    if (
      this.analysisInfo1h.macd > 0 &&
      this.analysisInfo1h.ema5W10A20Days >= 80 &&
      this.analysisInfo1h.kdjDiff > 0
    ) {
      this.setBuy('buyIfMacdUpManyDays-10-2', {
        canReverse: true
      })
    }
    if (
      this.indexIfMarketUpTrendBtbUp() &&
      this.analysisInfo15m.ema5W10A20Days >= 8 &&
      this.analysisInfo15m.macdUpDays >= 30 &&
      kdjDiff15mOK
    ) {
      this.setBuy('buyIfEmaUpManyDays-11', {
        canReverse: true
      })
    }
  },
  // 5和10大20大于32天，然后macd上面3天kdj上，小时的kdj8天macd上4天，也买入
  buyIfEmaUpManyDays () {
    const kdjDiff15mOK = this.analysisInfo15m.kdjDiff > 0 ||
      (this.marketFlagInfo.indexIfMarketUpTrend && this.strategy === '1' && this.analysisInfo15m.isKdjIncrease) ||
      (this.strategy === '1' && this.marketFlagInfo.ifMarket4hMacdEmaAllGood && this.marketFlagInfo.ifMarket1hMacdEmaAllGood && this.analysisInfo15m.isKdjIncrease)
    if (
      this.analysisInfo15m.ema5W10A20Days >= 32 &&
      this.analysisInfo15m.macdUpDays >= 3 &&
      kdjDiff15mOK
    ) {
      if (
        this.analysisInfo1h.kdjUpDays >= 8 ||
        this.analysisInfo1h.macdUpDays >= 4
      ) {
        this.setBuy('buyIfEmaUpManyDays-1', {
          canReverse: true
        })
      }
    }
    if (
      this.analysisInfo15m.ema5W10A20Days >= 44 &&
      this.analysisInfo15m.macdUpDays >= 3 &&
      kdjDiff15mOK
    ) {
      if (
        this.analysisInfo1h.ema5W10A20Days >= 10 &&
        this.analysisInfo1h.macdUpDays >= 10
      ) {
        this.setBuy('buyIfEmaUpManyDays-2', {
          canReverse: true
        })
      }
    }
    if (
      this.analysisInfo1h.ema5W10A20Days >= 20 &&
      this.analysisInfo1h.macdUpDays >= 20
    ) {
      if (
        this.analysisInfo15m.ema5W10A20Days >= 44 &&
        this.analysisInfo15m.macd > 0 &&
        kdjDiff15mOK
      ) {
        this.setBuy('buyIfEmaUpManyDays-3', {
          canReverse: true
        })
      }
    }
    // if (
    //   this.analysisInfo15m.ema5W10A20Days >= 40 &&
    //   this.analysisInfo15m.macd > 0 &&
    //   kdjDiff15mOK
    // ) {
    //   if (
    //     (
    //       this.analysisInfo1h.ema5W10A20Days >= 20 ||
    //       this.analysisInfo1h.macdUpDays >= 20
    //     ) &&
    //     this.analysisInfo1h.macd > 0 &&
    //     this.analysisInfo1h.ema5W10A20Days >= 1 &&
    //     this.analysisInfo1h.kdjUpDays >= 6
    //   ) {
    //     this.setBuy('buyIfEmaUpManyDays-4', {
    //     })
    //   }
    // }
    if (
      this.analysisInfoFlag15m.countIf5W10A20Times(72, 70) &&
      this.analysisInfo15m.ema5W10A20Days >= 10 &&
      this.analysisInfo15m.macd > 0 &&
      kdjDiff15mOK
    ) {
      this.setBuy('buyIfEmaUpManyDays-5', {
        canReverse: true
      })
    }
    // if (
    //   this.analysisInfoFlag15m.getNetChangeRatioUpDaysInRange(10).days >= 9 &&
    //   this.analysisInfo15m.netChangeRatioUpDays >= 2 &&
    //   this.analysisInfo15m.macdUpDays >= 5 &&
    //   kdjDiff15mOK
    // ) {
    //   if (
    //     this.analysisInfo1h.kdjDiff > 0
    //   ) {
    //     this.setBuy('buyIfEmaUpManyDays-6', {
    //       canReverse: true
    //     })
    //   }
    // }
    if (
      this.analysisInfo4h.ema5W10A20Days >= 6 &&
      this.analysisInfo4h.macdUpDays >= 6 &&
      this.analysisInfo1h.ema5W10A20Days >= 32 &&
      this.analysisInfo1h.macdUpDays >= 52 &&
      this.analysisInfo15m.ema5W10A20Days >= 52 &&
      this.analysisInfo15m.isDuo > 0
    ) {
      if (this.strategy === '2') {
        this.setBuy('buyIfEmaUpManyDays-7', {
          canReverse: true
        })
      }
    }
  },
  // 15分钟进攻
  buyIfAttack15m () {
    if (this.marketInfo && this.marketInfo.attack15m) {
      if (
        this.analysisInfo15m.macd > 0 &&
        this.analysisInfo15m.kdjDiff > 0 &&
        this.analysisInfo15m.ema5W10A20Days >= 1
      ) {
        if (
          this.analysisInfo1h.macdUpDays >= 5 &&
          this.analysisInfo1h.ema5W10A20Days >= 10
        ) {
          if (this.strategy === '2') {
            // 简直就是反向指标
            this.setBuy('buyIfAttack15m-1', {
              canReverse: true
            })
          }
        }
        if (
          this.analysisInfo1h.macdUpDays >= 10 &&
          this.analysisInfo1h.ema5W10A20Days >= 5
        ) {
          if (this.strategy === '2') {
            // 简直就是反向指标
            this.setBuy('buyIfAttack15m-2', {
              canReverse: true
            })
          }
        }
      }
      if (this.marketInfo.onlyDuo) {
        if (
          this.analysisInfo15m.macd > 0 &&
          this.analysisInfo15m.kdjDiff > 0 &&
          this.analysisInfo15m.ema5W10A20Days >= 1 &&
          this.analysisInfo1h.macd > 0 &&
          this.analysisInfo1h.kdjDiff > 0 &&
          this.analysisInfo1h.ema5W10A20Days >= 1 &&
          // 第一波共振
          this.analysisInfo1h.ema5W10A20Days <= 10 &&
          this.analysisInfo15m.ema5W10A20Days <= 10 &&
          this.marketInfo.min50AvRate > 0
        ) {
          if (this.strategy === '2') {
            this.setBuy('buyIfAttack15m-3', {
              canReverse: true
            })
          }
        }
      }
    }
    if (this.marketFlagInfo.ifMarket15mAllGood3Days) {
      // 3天了
      if (this.strategy === '2') {
        if (
          this.analysisInfo15m.ema5W10A20Days >= 20 &&
          this.analysisInfo15m.macd > 0 &&
          this.analysisInfo15m.kdjDiff > 0 &&
          this.analysisInfo1h.ema5W10A20Days >= 4 &&
          this.analysisInfo1h.macd > 0 &&
          this.analysisInfo1h.kdjDiff > 0
        ) {
          this.setBuy('buyIfAttack15m-4', {
            canReverse: true
          })
          this.ifCanIgnoreNoSell = true
          this.ifCanIgnoreNobuy = true
        }
        if (
          this.analysisInfo15m.ema5W10A20Days >= 12 &&
          this.analysisInfo15m.macd > 0 &&
          this.analysisInfo15m.kdjDiff > 0 &&
          this.analysisInfo1h.ema5W10A20Days >= 20 &&
          this.analysisInfo1h.macd > 0 &&
          this.analysisInfo1h.kdjDiff > 0
        ) {
          this.setBuy('buyIfAttack15m-4-1', {
            canReverse: true
          })
          this.ifCanIgnoreNoSell = true
          this.ifCanIgnoreNobuy = true
        }
        if (
          this.analysisInfo15m.ema5W10A20Days >= 14 &&
          this.analysisInfo15m.ema5W10A20Rate >= 4 &&
          this.analysisInfo15m.ema5A10A20Days >= 1 &&
          this.analysisInfo15m.macdUpDays >= 14 &&
          this.analysisInfo15m.kdjDiff > 0 &&
          this.analysisInfo1h.isDuo
        ) {
          this.setBuy('buyIfAttack15m-4-2', {
            canReverse: true
          })
          this.ifCanIgnoreNoSell = true
          this.ifCanIgnoreNobuy = true
        }
        if (
          this.analysisInfo15m.ema5W10A20Days >= 8 &&
          this.analysisInfo15m.ema5W10A20Rate >= 4 &&
          this.analysisInfo15m.ema5A10A20Days >= 1 &&
          this.analysisInfo15m.macdUpDays >= 14 &&
          this.analysisInfo15m.kdjUpDays >= 14 &&
          this.analysisInfo1h.isDuo
        ) {
          // 时间太短了做反向的话
          this.setBuy('buyIfAttack15m-4-3', {
            canReverse: true
          })
          this.ifCanIgnoreNoSell = true
          this.ifCanIgnoreNobuy = true
        }
        if (
          this.analysisInfo15m.ema5W10A20Days >= 3 &&
          this.analysisInfo15m.ema5W10A20Days <= 8 &&
          this.analysisInfo15m.ema5A10A20Days >= 1 &&
          this.analysisInfo15m.macdUpDays >= 32
        ) {
          this.setBuy('buyIfAttack15m-4-4', {
            canReverse: true
          })
          this.ifCanIgnoreNoSell = true
          this.ifCanIgnoreNobuy = true
        }
      }
    }
  },
  buyIfHighFrequency () {
    if (
      this.analysisInfo1h.kdjUpDays >= 8 &&
      this.analysisInfo1h.macdUpDays >= 8 &&
      this.analysisInfo1h.ema5A10A20Days >= 1 &&
      (
        this.marketFlagInfo.ifMarket15mMacdEmaAllBad ||
        this.marketFlagInfo.ifMarket15mMacdEmaAllGood
      )
    ) {
      if (
        this.analysisInfo15m.macd > 0 &&
        this.analysisInfo15m.kdjDiff > 0 &&
        this.analysisInfo15m.ema5A10A20Days >= 1
      ) {
        if (this.strategy === '1') {
          if (
            this.analysisInfo1h.macdUpKeepInfo.rrncs < 0.3 ||
            this.analysisInfo1h.macdUpKeepInfo.mdrr > 0.5 ||
            this.analysisInfo1h.kdjUpKeepInfo.rrncs < 0.3 ||
            this.analysisInfo1h.kdjUpKeepInfo.mdrr > 0.5
          ) {
            return
          }
          this.setBuy('buyIfHighFrequency-1', {
            canReverse: true
          })
        } else {
          this.setBuy('buyIfHighFrequency-2', {
            canReverse: true
          })
        }
      }
    }
    if (!this.marketInfo.kdj1dGood && !this.marketInfo.kdj4hGood && !this.marketInfo.kdj1hGood) {
      if (!this.marketInfo.macd1hGood && !this.marketInfo.ema1hGood) {
        if (this.analysisInfo15m.netChangeRatio > 13) {
          if (this.strategy === '2') {
            this.setBuy('buyIfHighFrequency-6', {
              canReverse: true
            })
          }
        }
        if (this.analysisInfo15m.highOpenRate > 20 && this.analysisInfo15m.netChangeRatio > 10) {
          if (this.strategy === '2') {
            this.setBuy('buyIfHighFrequency-6-1', {
              canReverse: true
            })
          }
        }
      }
    }
  }
}
